package com.googlecode.imule.plugin;

import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IObjectActionDelegate;
import org.eclipse.ui.IWorkbenchPart;

public class ASTManifestAction implements IObjectActionDelegate{

	private ISelection selection;
	

	public void setActivePart(IAction action, IWorkbenchPart targetPart) {	
	}
	
	public void run(IAction action) {
		if (selection instanceof ISelection) {
			ICompilationUnit lwUnit = (ICompilationUnit) ((IStructuredSelection) selection)
					.getFirstElement();
			createActionExuecutable(action.getId()).run(lwUnit);
		}
	}
	
	public void selectionChanged(IAction action, ISelection selection) {
		this.selection = selection;
		
	}
	
	private ASTAbstractManifest createActionExuecutable(String id) {
		if ("com.googlecode.imule.plugin.astManifestAction1".equals(id)) {
			
			
			return new ASTManifest();
		} else {
			throw new IllegalArgumentException(id);
		}
	}
	
	
}
